<?php

class Public_Post_RedirectAction extends BlogPublicBaseAction
{
    public function executeRead(AgaviRequestDataHolder $rd)
    {
        /* @var $model Public_PostsModel */
        $model = $this->getContext()->getModel('Posts', 'Public');
        $shortcut = $rd->getParameter('shortcut');
        
        $post = $model->getPost(null, $shortcut);
        if (is_null($post)) {
            return array('Public', 'Error404Success');
        }
        
        $this->setAttribute('post', $post);
        return 'Success';
    }
    
    public function executeWrite(AgaviRequestDataHolder $rd)
    {
        return array('Public', 'Error404Success');
    }
    
	/**
	 * Returns the default view if the action does not serve the request
	 * method used.
	 *
	 * @return     mixed <ul>
	 *                     <li>A string containing the view name associated
	 *                     with this action; or</li>
	 *                     <li>An array with two indices: the parent module
	 *                     of the view to be executed and the view to be
	 *                     executed.</li>
	 *                   </ul>
	 */
	public function getDefaultViewName()
	{
		return 'Success';
	}
}

?>